/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Home.java
 *
 * Created on 2 juin 2009, 14:44:50
 */

package caylus.GUI;

import caylus.Model.Croupier;
import caylus.Model.Load;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author CeZar
 */
public class Home extends javax.swing.JFrame {

    private Configuration _fenetreConfiguration ;
    private ChargerPartie _fenetreChargerPartie ;
    /** Creates new form Home */
    public Home() {
        initComponents();
        centrerFenetre();
    }
    /**
     * methode pour centrer la fenetre dans l'ecran
     */
    private void centrerFenetre()
        {
            // on place notre fenêtre au milieu
            Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
            setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2);
        }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelNouvellePartie = new javax.swing.JLabel();
        jLabelChargerPartie = new javax.swing.JLabel();
        jLabelQuitter = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Caylus - Accueil");

        jPanel1.setBackground(new java.awt.Color(255, 255, 204));

        jLabelNouvellePartie.setFont(new java.awt.Font("Verdana", 3, 36)); // NOI18N
        jLabelNouvellePartie.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/StartIcon.png"))); // NOI18N
        jLabelNouvellePartie.setText("Nouvelle Partie");
        jLabelNouvellePartie.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelNouvellePartieMouseClicked(evt);
            }
        });

        jLabelChargerPartie.setFont(new java.awt.Font("Verdana", 3, 36)); // NOI18N
        jLabelChargerPartie.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/LoadIcon.png"))); // NOI18N
        jLabelChargerPartie.setText("Charger Partie");
        jLabelChargerPartie.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelChargerPartieMouseClicked(evt);
            }
        });

        jLabelQuitter.setFont(new java.awt.Font("Verdana", 3, 36)); // NOI18N
        jLabelQuitter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/caylus_button_cancel.png"))); // NOI18N
        jLabelQuitter.setText("Quitter");
        jLabelQuitter.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelQuitterMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(75, 75, 75)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelQuitter)
                    .addComponent(jLabelChargerPartie)
                    .addComponent(jLabelNouvellePartie, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(111, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addComponent(jLabelNouvellePartie)
                .addGap(18, 18, 18)
                .addComponent(jLabelChargerPartie)
                .addGap(18, 18, 18)
                .addComponent(jLabelQuitter)
                .addContainerGap(66, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jLabelNouvellePartieMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelNouvellePartieMouseClicked
        _fenetreConfiguration = new Configuration();
        this.setVisible(false);
        _fenetreConfiguration.setVisible(true);
}//GEN-LAST:event_jLabelNouvellePartieMouseClicked

    private void jLabelChargerPartieMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelChargerPartieMouseClicked
        _fenetreChargerPartie = new ChargerPartie();
        this.setVisible(false);
        // chargement des donnees
        Load charge = new Load("C:\\CAYLUS\\sauvegarde.txt");
        // recuperation :
        PlateauDuJeu Plateau_charge = new PlateauDuJeu(charge.GeneralsSettings_Recuperé);
        // recuperation Croupier
       Plateau_charge._leCroupier.set_joueurs(charge.ListeJoueur_Récuperé);


        // affectation du Croupier au nouveau plateau de jeu
        Plateau_charge._leCroupier = new Croupier(charge.GeneralsSettings_Recuperé, Plateau_charge);
        Plateau_charge.setVisible(true);

}//GEN-LAST:event_jLabelChargerPartieMouseClicked

    private void jLabelQuitterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelQuitterMouseClicked
        setVisible(false);
        this.dispose();
}//GEN-LAST:event_jLabelQuitterMouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Home().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabelChargerPartie;
    private javax.swing.JLabel jLabelNouvellePartie;
    private javax.swing.JLabel jLabelQuitter;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
